﻿* Encoding: UTF-8.
compute corr2016=valid2016.
recode corr2016 (1,4=2)(2,3=1).
value labels corr2016 1 'Did not vote' 2 'Voted'.
freq corr2016.

compute or2016=valid2016.
recode or2016 (3=1)(2,1,4=0).
value labels or2016 1 'Did not vote' 2 'Voted'.
missing values or2016 (-99).
freq or2016.

*** ENGAGEMENT ***

compute vote16pc=qv45a.
value labels vote16pc 1 'Voted in primary or caucus' 0 'Not'.
recode vote16pc (1=1)(2=0)(77=0)(98,99=-99).
freq vote16pc.

compute contrib16=qv45d.
value labels contrib16 1 'Contributed' 0 'Not'.
recode contrib16 (1=1)(2=0)(77=0)(98,99=-99).
freq contrib16.

compute sign16=qv45f.
value labels sign16 1 'Displayed sign button sticker' 0 'Not'.
recode sign16 (1=1)(2=0)(77=0)(98,99=-99).
freq sign16.

freq qv42.
compute follow16=qv42.
if (follow16 eq -99) follow16=rq64.
value labels follow16 1 'Not much' 2 'Occasionally' 3 'Moderately closely' 4 'Very closely'.
recode follow16 (1=4)(2=3)(3=2)(4=1)(77=1)(98=-99)(99=-99)(sysmis=0).
freq follow16.

freq follow16 vote16pc contrib16 sign16.

weight by mweight.
missing values  follow16 vote16pc contrib16 sign16 (-99).
descriptives var=follow16 vote16pc contrib16 sign16 /save.

freq zfollow16 vote16pc zcontrib16 zsign16.

compute engage16fa = (zfollow16*.47)+(zvote16pc*.29)+(zcontrib16*.65)+(zsign16*.58).
freq engage16fa/stat=mean std.

compute engage16ix=rnd(10*(engage16fa+1.78)/5.62).
freq engage16ix/stat=mean std semean. 

freq engage16ix.

compute engage16r5 = engage16ix.
recode engage16r5 (0,1=0)(2,3=1)(4,5,6=2)(7,8=3)(9,10=4).
freq engage16r5.


*** INTEREST ***

weight by mweight.

compute qv2_kr=QQ2_11.
recode qv2_kr (1=3)(2=2)(3=1)(77=1)(98,99=-99)(sysmis=-99).
value labels qv2_kr 1 'Not at all' 2 'Moderately' 3 'Very'.
freq qv2_kr.

compute PEint=0.
if (qv2_kr ge 1) PEint=qv2_kr.
recode PEint (0=-99).
value labels PEint 1 'Not at all' 2 'Moderately' 3 'Very'.
freq PEint.

compute qv42r=qv42.
recode qv42r (1=4)(2=3)(3=2)(4=1)(77=1)(98,99=-99)(sysmis=-99).
value labels qv42r 1 'Not much' 2 'Occasionally' 3 'Moderately closely' 4 'Very closely'.
freq qv42r.

compute PEfollow=0.
if (qv42r ge 1) PEfollow=qv42r.
value labels PEfollow 1 'Not much' 2 'Occasionally' 3 'Moderately closely' 4 'Very closely'.
recode PEfollow (0=-99).

compute qv46ar=qv46a.
recode qv46ar (-9, 0=1)(1 thru 10=2)(11 thru 40=3)(41 thru 100=4)(101 thru 760=5)(800,900, 999=5)(777,7777=1)(998,9998=1)(9999=-99)(sysmis=-99).
value labels qv46ar 1'None' 2'1-10' 3'11-40' 4'41-100' 5'101 to 999'.
missing values qv46ar ().

compute PEnewsp=0.
if (qv46ar ge 1) PEnewsp=qv46ar.
value labels PEnewsp 1 'None' 2 '1-10' 3 '11-40' 4 '41-100' 5 '101 to 999'. 
recode PEnewsp (0=-99).
freq PEnewsp.

compute qv46br=qv46b.
recode qv46br (-9, 0=1)(1 thru 10=2)(11 thru 30=3)(31 thru 700=4)(800,900, 999=4)(777,7777=1)(998,9998=1)(9999=-99)(sysmis=-99).
value labels qv46br 1'None' 2'1-10' 3'11-30' 4'31-999'.
missing values qv46br ().

compute PEmags=0.
if (qv46br ge 1) PEmags=qv46br.
value labels PEmags 1 'None' 2 '1-10' 3 '11-30' 4 '31 or more'.
recode PEmags (0=-99).

compute qv46cr=qv46c.
recode qv46cr (-9,0=1)(1 thru 10=2)(11 thru 40=3)(41 thru 100=4)(101 thru 760=5)(800,900,999=5)(777,7777=1)(998,9998=1)(9999=-99)(sysmis=-99).
value labels qv46cr 1 'None' 2 '1-10' 3 '11-40' 4 '41-100' 5 '101-999'.

compute PEonline=0.
if (qv46cr ge 1) PEonline=qv46cr.
value labels PEonline 1 'None' 2 '1-10' 3 '11-40' 4 '41-100' 5 '101-999'.
recode PEonline (0=-99).

compute qv46ir=qv46i.
recode qv46ir (-9, 0=1)(1 thru 10=2)(11 thru 20=3)(21 thru 50=4)(51 thru 700=5)(-60=-99)(900,990,999=5)(777,7777=1)(998,9998=1)(9999=-99)(sysmis=-99).
value labels qv46ir 1 'None' 2 '1-10' 3 '11-40' 4 '41-100' 5 '101-999'.
missing values qv46ir ().

compute PEfriends=0.
if (qv46ir ge 1) PEfriends=qv46ir.
value labels PEfriends 1 'None' 2 '1-10' 3 '11-40' 4 '41-100' 5 '101-999'.
recode PEfriends (0=-99).

compute qv46lr=qv46l.
recode qv46lr (-9,0=1)(1 thru 10=2)(11 thru 30=3)(31 thru 90=4)(91 thru 500=5)(720,750,800,999=5)(777,7777=1)(998,9998=1)(9999=-99)(sysmis=-99).
value labels qv46lr 1 'None' 2 '1-10' 3 '11-30' 4 '31-90' 5 '91-999'.
missing values qv46lr ().

compute PEtalkws=0.
if (qv46lr ge 1) PEtalkws=qv46lr.
value labels PEtalkws 1 'None' 2 '1-10' 3 '11-30' 4 '31-90' 5 '91-999'.
freq PEtalkws.

weight by mweight.
freq PEint PEfollow PEnewsp PEmags PEonline PEfriends PEtalkws.

compute polint16r3=1.
if ((PEint ge 2) and (PEfollow ge 3)) polint16r3=2.
if ((PEint eq 3) and (PEfollow eq 4)) polint16r3=3.
value labels polint16r3 1 'Low' 2 'Moderate' 3 'High'.

weight by mweight.
missing values PEint PEfollow PEnewsp PEmags PEonline PEfriends PEtalkws (-99).
descriptives var=PEint PEfollow PEnewsp PEmags PEonline PEfriends PEtalkws/save.

compute polint16fa=(zpeint*.48)+(zpefollow*.63)+(zpenewsp*.74)+(zpemags*.69)+(zpeonline*.84)+(zpefriends*.90)+(zpetalkws*.79).
freq polint16fa/stat=mean std.

compute polint16ix=rnd(10*(polint16fa+5.49)/15.75).
freq polint16ix/stat=mean std semean. 
recode polint16ix (sysmis=-99).
missing values polint16ix (-99).
freq polint16ix.

compute polint16r5=polint16ix.
recode polint16r5 (0,1=1)(2,3=2)(4,5,6=3)(7,8=4)(9,10=5).
value labels polint16r5 1 '0-1' 2 '2-3' 3 '4-6' 4 '7-8' 5 '9-10'.
freq polint16r5.
missing values polint16r5 (-99).


weight by mweight.
*Table 1

freq valid2016.

*Table 6

crosstabs polint16r5 by valid2016/cells=count row/stat=gamma.
crosstabs polint16r5 by corr2016/cells=count row/stat=gamma.
crosstabs polint16r5 by or2016/cells=count row/stat=gamma.

crosstabs engage16r5 by valid2016/cells=count row/stat=gamma.
crosstabs engage16r5 by corr2016/cells=count row/stat=gamma.
crosstabs engage16r5 by or2016/cells=count row/stat=gamma.

*Table 7

crosstabs nparty7 by valid2016/cells=count row/stat=gamma.
crosstabs nparty7 by corr2016/cells=count row/stat=gamma.
crosstabs nparty7 by or2016/cells=count row/stat=gamma.

crosstabs ipart by valid2016/cells=count row/stat=gamma.
crosstabs ipart by corr2016/cells=count row/stat=gamma.
crosstabs ipart by or2016/cells=count row/stat=gamma.

*Ideological Partisanship by geography

crosstabs nparty7 by valid2016 by statetype/cells=count row/stat=gamma.
crosstabs nparty7 by corr2016 by statetype/cells=count row/stat=gamma.
crosstabs nparty7 by or2016 by statetype/cells=count row/stat=gamma.


